import Vue from 'vue'
import VueRouter from 'vue-router'
import Login from '../views/login/login.vue'



Vue.use(VueRouter)

const routes = [
  {
    path: '/',
    component: () => import('../views/layout/layout.vue'),
    children: [
      // 默认显示这个二级路由
      {
        path: '',
        name: 'home',
        component: () => import('../views/home/home.vue')
      },
      {
        path: 'question',
        name: 'question',
        component: () => import('../views/question/question.vue')
      },
      {
        path: 'video',
        name: 'video',
        component: () => import('../views/video/video.vue')
      },
      {
        path: 'setting',
        name: 'setting',
        component: () => import('../views/setting/setting.vue')
      }
    ]
  },
  {
    path: '/login',
    name: 'login',
    component: Login
    // route level code-splitting
    // this generates a separate chunk (about.[hash].js) for this route
    // which is lazy-loaded when the route is visited.
    // component: () => import(/* webpackChunkName: "about" */ '../views/About.vue')
  },
  {
    path: '/search',
    name: 'search',
    component: () => import('../views/search/search.vue')
  },
  {
    path: '/search/result',
    name: 'result',
    component: () => import('../views/search/result.vue')
  },
  {
    path: '/article/:id',
    name: 'article',
    component: () => import('../views/article/article.vue')
  },
  {
    path: '/setting/chat',
    name: 'chat',
    component: () => import('../views/setting/chat.vue')
  },
  {
    path: '/setting/profile',
    name: 'profile',
    component: () => import('../views/setting/profile.vue')
  }
]
const originalPush = VueRouter.prototype.push
VueRouter.prototype.push = function push (location, onResolve, onReject) {
  if (onResolve || onReject) return originalPush.call(this, location, onResolve, onReject)
  return originalPush.call(this, location).catch(err => err)
}
const router = new VueRouter({
  routes
})


export default router
